1 using UnityEngine;
2 using
System.Collections;
3
4 public
class CarPassingBy : MonoBehaviour {
5
6     AudioSource audioSource;
7     
public AudioClip clip;
8     
// Use this for initialization
9     
void Start () {
10         audioSource = GetComponent<AudioSource> ();
11     
12     }
13     
14     
// Update is called once per frame
15     
void Update () {
16     
17     }
18
19
20     
void OnTriggerEnter(Collider other){
21         
if (other.gameObject.tag == "Player" ) {
22             audioSource.PlayOneShot (clip);
23
24         }
25     }
26 }


Gõ tìm kiếm nhanh...